C-based file operations
In ANSI C, the operation of the file is divided into two ways, that is, streaming file operations and I/O file operations, respectively, described below.
One, streaming file operation
The file operations in this way have an
So far, the input and output we have discussed is the object of the system-specified standard device (the input device is the keyboard and the output device is the monitor). In real-world applications, disk files are often used as objects. The data
Fgets (read a string from the file)Related functions: open, fread, fscanf, GETCHeader file include Define the function char * fgets (char * s, int size, file * stream );Function Description: fgets () is used to read characters from the file referred
1
C file operations
FileBasic concepts of FilesThe so-called "file" refers to an ordered set of related data. This dataset has a name called a file name. In fact, we have used files many times in the
FILE descriptor and FILE, FILE descriptor FILE1. file descriptor (important)
In Linux, everything can be viewed as a file, which can be divided into common files, directory files, link files, and device files. File descriptor is an index created by
Linux virtual file system four main objects:1) Super Block2) Index node (inode)3) Catalog entry (dentry)4) Document object (file)A process that refers to various objects as it operates on a file is as follows:by Task_struct get files_struct, then
C file operation functionsClearerr (error flag for clearing file streams)FeofHeader file # include Define the void clearerr (File * stream) function );Function Description clearerr () clears the error flag used by the file stream specified by the
Linux file type and vice file name
Always emphasize a concept, that is: Any device under Linux are files, not only that, even the interface of data communication has a proprietary file in charge ~ So, you will? solution, Linux file type is really a
fopen (Open file)Correlation function Open,fclose
Table header file #include
Defines the function FILE * fopen (const char * path,const char * mode);
The function description parameter path string contains the file path and filename to open, and
It mainly includes php file processing, file processing, file pointer-related processing functions, file control functions, including PHP file processing, file processing, file pointer-related processing functions, and file control functions.
PHP
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.